<!--# include virtual="/admin/common/html/header.html"-->
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 政策法规 <span class="c-gray en">&gt;</span> 政策法规审核 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c">
	 <span class="select-box inline">
		<select name="state"  id="state" class="select" >
			<option value="" >全部分类</option>
			<option value="0" selected="selected">待审核</option>
			<option value="1">已审核</option>
			<option value="2">未通过</option>
		</select>
		</span> 日期范围：
		<input type="text" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'maxupdateTime\')||\'%y-%M-%d\'}' })" id="minupdateTime" name="minupdateTime" class="input-text Wdate" style="width:120px;">
		-
		<input type="text" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'minupdateTime\')}',maxDate:'%y-%M-%d' })" id="maxupdateTime" name="maxupdateTime" class="input-text Wdate" style="width:120px;">
		<input type="text" name="titles" id="titles" placeholder="文章标题" style="width:250px" class="input-text">
		<button name="searchButton" id="searchButton" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i>搜索	</button>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
		<span class="l">
			<a href="javascript:;" onclick="batchCheck()" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量审核</a> 
		<!--<a class="btn btn-primary radius" data-title="批量审核" data-href="article-add.html" onclick="Hui_admin_tab(this)" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i>批量审核</a>-->
		</span> <span class="r"></span> </div>
	<div class="mt-20">
		<table id="firm-post-list"  class="table table-border table-bordered table-bg table-hover table-sort">
			<thead>
				<tr class="text-c">
					<th ><input type="checkbox" name="test" value=""></th>					
					<!--<th >ID</th>-->
					<th >标题</th>
					<!--<th >关键字</th>-->
					<th >文号</th>
					<!--<th >发文机关</th>-->
					<th >所属分类</th>
					<th >时效性</th>
					<!--<th >访问量</th>-->
					<th >创建时间</th>
					<th  class=".td-status">状态</th>
					<th >操作</th>									
				</tr>
			</thead>
			<tbody ></tbody>
		</table>				
	</div>
</div>
<!--# include virtual="/admin/common/html/_footer.html"-->
<script type="text/javascript">
$(function () {
    var $table_id = $("#firm-post-list");
    var user = {
        getQueryCondition: function (data) {
            var param = {};
            param.state= $.trim($("#state option:selected").val());
            param.minupdateTime= $.trim($("#minupdateTime").val());
            param.maxupdateTime= $.trim($("#maxupdateTime").val());
            param.titles= $.trim($("#titles").val());                              
            param.pageNumber = (data.start/data.length) || 1;;
            param.pageSize = data.length || 15;;
            param.draw = data.draw;
            return param;
        }
    };
    //object可以如下初始化表格
     var dataTable = $table_id.DataTable({
        dom: '<".table_area_top" B and >t<".table_area_bottom" pi>',
        Filter: false, //列筛序功能
        searching: false,//本地搜索
        ordering: true, //排序功能
        Info: true,//页脚信息
        lengthMenu: [15],//定义每页显示数据数量
        scrollY: "auto",
        Paginate: true, //翻页功能
        sortable: false,
        processing: true,
        serverSide: true,      
        ajax: function (data, callback){//ajax配置为function,手动调用异步查询
            $.post("/guidance_service/front/policies/search.do",user.getQueryCondition(data),function(result){
        		var returnData = {};   //封装返回数据，这里仅演示了修改属性名
                returnData.recordsTotal = result.data.totalRow;  //result.ext.recordsTotal;
                returnData.recordsFiltered =result.data.totalRow; //result.ext.recordsFiltered;//后台不实现过滤功能，每次查询均视作全部结果
                returnData.data =   result.data.list;  //result.data.;
                callback(returnData);
    		});
        },
        columns: [  //使用对象数组，一定要配置columns，告诉 DataTables 每列对应的属 //data 这里是固定不变的，id，name，age，sex等为你数据里对应的属性
            { 
                data: "policiesId",
                render: function (data) {
					return '<input type="checkbox" name="policiesId" value="'+data+'" class="Id">';
                }
            },
            {
                data: "titles",
                render: function (data,type,row) {
//						return data || "";
//                      return '<a href="/guidance_service/front/policies/detail.do?titles='+data+'">'+data+'</a>';
                    return '<a onClick="policies_edit(this,\'detail.html?policiesId='+row.policiesId+'\')" href="javascript:;" >'+data+'</a>';
                }
            },
            {
                data: "source",//文号
                render: function (data) {
                	return data || "";
                }
            },  
//          {
//              data: "authors",//发文机关
//              render: function (data) {
//			  		return data || "";
//              }
//    	    },
            {
                data: "fieldId",
                render: function (data) {
                	//sessionStorage.setItem("fieldId",data)
                	//return sessionStorage.getItem(data);
                	return data || "";
                }
            },  
            {
                data: "timeliness",
                render: function (data) {
					return data;
                }
            },
            /*{
                data: "pageview",
                render: function (data) {
					return data || "";
                }
            },*/
            {
                data: "createTime",//发布时间
                render: function (data,type,row) {
                	return data;
                }
            }, 
            {
                data: "state",//状态
                render: function (data) {
                    if ('0'==data) {
                    	return '<span class="label label-primary  radius">申请中</span>';
                    }else if('1'==data){
                    	return '<span class="label label-success  radius">已通过</span>';
                    }else if('2'==data){
                    	return '<span class="label label-warning  radius">未通过</span>';
                    }
                }
            },  
            {
                data: "policiesId",                      
                render: function (data,type,row) {
                	return '<a  class="label label-danger  radius" style="text-decoration:none" onClick="policies_shenhe(this,'+data+')" href="javascript:;" title="审核">审核</a>'
                }
            }
        ],
        language: { //国际语言转化
            aria: {
                sortAscending: " - click/return to sort ascending",
                sortDescending: " - click/return to sort descending"
            }, 
            lengthMenu: "显示 _MENU_ 记录",
            zeroRecords: "对不起，查询不到任何相关数据",
            emptyTable: "未有相关数据",
            loadingRecords: "正在加载数据-请等待...",
            info: "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录。",
            infoEmpty: "当前显示0到0条，共0条记录",
            infoFiltered: "（数据库中共为 _MAX_ 条记录）",
            processing: " 正在加载数据...",
            //多语言配置文件，可将oLanguage的设置放在一个txt文件中，例：Javascript/datatable/dtCH.txt
            paginate: {
                first: "首页",
                previous: " 上一页 ",
                next: " 下一页 ",
                last: " 尾页 "
            }
        },
        "drawCallback": function (settings) {
            var api = this.api();
        }
    });

    $("#searchButton").on("click", function () {
        dataTable.draw();
    });

    $("thead").find("input").on("change", ":checkbox", function (event) {
        if ($(this).is("[name='checkBtn']")) {
            //全选
            $(":checkbox", $table_id).prop("checked", $(this).prop("checked"));
        } else {
            //一般复选
            var checkbox = $("tbody :checkbox", $table_id);
            $(":checkbox[name='checkBtn']", $table_id).prop('checked', checkbox.length == checkbox.filter(':checked').length);
        }
        return false;
    }).on("click", ".td-checkbox", function (event) {
        //点击单元格即点击复选框
        !$(event.target).is(":checkbox") && $(":checkbox", this).trigger("click");
        return false;
    })
});
</script> 
<script type="text/javascript">
$(function(){
	$.post("/guidance_service/front/policies/field/getField.do",{},function(result){
		if(result.resultCode == 200){
			$.each(result.data,function(i,field){
				$("#fieldSelect").append("<option value='"+this.fieldId+"'>"+this.fieldName+"</option>");
			});
		}else{
			layer.msg(result.message,{icon:2,time:1000});
		}
	});
});

//批量删除
function deletes(){
	var Ids ="";  
	$('input[name="policiesId"]:checked').each(function(){    
		Ids+=$(this).val()+",";    
	});
	layer.confirm('确认要删除吗？',function(index){
		$.post("/guidance_service/front/policies/logicDeleteAll.do",{"policiesIds":Ids},function(result){
			if(result.resultCode == 200){
				layer.msg('已删除!',{icon:1,time:1000},function(){
					layer.close(index);
				});
			}else{
				layer.msg(result.message,{icon:2,time:1000},function(){
					layer.close(index);
				});
			}
		});
	});
}

/*审核*/
function policies_shenhe(obj,policiesId){
	layer.confirm('审核申请？', {
		btn: ['通过','不通过','取消'], 
		shade: false,
		closeBtn: 0
	},function(index){
		$.post("/guidance_service/front/policies/dataApplyCheck.do",{ policiesId:policiesId,state:1 },function(result){
			if(result.resultCode == 200){
				layer.msg("请求成功", {icon:6,time:1000},function(){
					//$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" data-id="'+$(obj).attr("data-id")+'"  onClick="article_start(this,10001)" href="javascript:;" title="开放"><i class="Hui-iconfont" style="font-size: 18px;">&#xe603;</i></a>');
					$(obj).parents("tr").find("span").removeClass().addClass("label label-success radius").text("已通过"); 
					//$(obj).remove();
					layer.close(index);
				});
			}else{
				layer.msg('操作失败', {icon:5,time:1000},function(){
					layer.close(index);
				});
			}
		});
	},function(index){
		$.post("/guidance_service/front/policies/dataApplyCheck.do",{ policiesId:policiesId,state:2 },function(result){
			if(result.resultCode == 200){
				layer.msg("请求成功", {icon:6,time:1000},function(){
					$(obj).parents("tr").find("span").removeClass().addClass("label label-warning  radius").text("未通过"); 
					layer.close(index);
				});
			}else{
				layer.msg('操作失败', {icon:5,time:1000},function(){
					layer.close(index);
				});
			}
		});
	});
}
//批量审核
function batchCheck(){
	var Ids ="";  
	$('input[name="policiesId"]:checked').each(function(){    
		Ids+=$(this).val()+",";    
	});
	policies_shenhe(this,Ids);
}

/*文章-编辑*/
function policies_edit(obj,url,id,w,h){
	var index = layer.open({
		type: 2,
		title: '',
		content: url
	});
	layer.full(index);
}
</script> 
</body>
</html>